﻿Public Class frmIssueRoomslc
    Private da As New DSVaultingTableAdapters.ir_issue_room_boxesTableAdapter
    Private dt As New DataTable

    Private Sub frmIssueRoomslc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DSVaulting.ir_issue_rooms' table. You can move, or remove it, as needed.
        Me.Ir_issue_roomsTableAdapter.Fill(Me.DSVaulting.ir_issue_rooms)
        Dim box As Integer = da.ScalarQueryBoxEInRoom(uxRoomCbx.SelectedValue)

        If box > 0 Then
            uxIOBoxCbx.Enabled = True
            uxIOBoxCbx.SelectedIndex = 0
        End If

    End Sub

    Private Sub uxCancelBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxCancelBtn.Click
        frmRoomSelecting.Enabled = True
        Me.Close()
    End Sub

    Private Sub frmIssueRoomslc_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        frmRoomSelecting.Enabled = True
    End Sub

    Private Sub uxOKBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxOKBtn.Click
        If uxIOBoxCbx.SelectedIndex = 1 Then
            frmIRBox.Show()
        ElseIf uxIOBoxCbx.SelectedIndex = 2 Then
            frmIRBoxUSD.Show()
        Else
            frmIssueRoom.Show()
        End If

        Me.Close()
    End Sub

    Private Sub uxRoomCbx_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxRoomCbx.SelectedIndexChanged
        Dim box As Integer = da.ScalarQueryBoxEInRoom(uxRoomCbx.SelectedValue)

        If box > 0 Then
            uxIOBoxCbx.Enabled = True
            uxIOBoxCbx.SelectedIndex = 0            
        End If
    End Sub

    Private Sub uxIOBoxCbx_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles uxIOBoxCbx.SelectedIndexChanged
        Dim idx As Integer = uxIOBoxCbx.SelectedIndex
        Dim ccy As String = ""
        If idx > 0 Then
            If idx = 1 Then
                ccy = "ប្រាក់រៀល"
            ElseIf idx = 2 Then
                ccy = "ប្រាក់ដុល្លារ"
            End If
            Dim row As Integer = da.GetDataByBox(uxRoomCbx.SelectedValue, ccy).Rows.Count
            If row > 0 Then
                uxBoxCbx.Enabled = True
                uxOKBtn.Enabled = True
                uxBoxCbx.DataSource = da.GetDataByBox(uxRoomCbx.SelectedValue, ccy)
                uxBoxCbx.DisplayMember = "BOX_NAME"
                uxBoxCbx.ValueMember = "BOX_ID"
            Else
                uxBoxCbx.Text = ""
                uxBoxCbx.Enabled = False
                uxOKBtn.Enabled = False
            End If
        Else
            uxBoxCbx.Text = ""
            uxBoxCbx.Enabled = False
        End If
    End Sub
End Class